package com.bsh.repository;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.bsh.mybatis.IRepository.AdminRoleMapper;
import com.bsh.mybatis.model.AdminRole;

@Repository
public class DaoAdminRole {
	@Resource
	SqlSessionTemplate session; 
	AdminRoleMapper getMapper(){
		return session.getMapper(AdminRoleMapper.class);
	}
		
	public int deleteByPrimaryKey(Integer id) {
		int res = getMapper().deleteByPrimaryKey(id);
		return res;
	}

	public int insert(AdminRole record) {
		int res = getMapper().insert(record);
		return record.getId();
	}

	public int insertSelective(AdminRole record) {
		int res = getMapper().insertSelective(record);
		return record.getId();
	}

	public AdminRole selectByPrimaryKey(Integer id) {
		AdminRole row = getMapper().selectByPrimaryKey(id);
		return row;
	}

	public int updateByPrimaryKeySelective(AdminRole record) {
		int res = getMapper().updateByPrimaryKeySelective(record);
		return res;
	}

	public int updateByPrimaryKey(AdminRole record) {
		int res = getMapper().updateByPrimaryKey(record);
		return res;
	}

	/**
	 * 移除管理员的角色 
	 * @param roleId
	 */
	public int removeByAdmin(int adminId){
		int res = getMapper().removeByAdmin(adminId);
		return res;
	}
	
	/**
	 * 按角色删除 
	 * @param roleId
	 */
	public int removeByRole(int roleId){
		int res = getMapper().removeByRole(roleId);
		return res;
	}
}
